﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BANSACH_GUI;
namespace BANSACH
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
      
        #region Menu Quản lý giao dịch
        private void mnuTracuuSach_Click(object sender, EventArgs e)
        {
            
        }

        private void mnuLapHoadon_Click(object sender, EventArgs e)
        {
            if (CheckExistForm("frmTblHOADONList")) return;
            // Tạo mới form Nhà xuất bản
            frmTblHOADONList childForm = new frmTblHOADONList();
            // Đặt thuộc tính MdiParent
            childForm.MdiParent = this;
            // Hiển thị
            childForm.Show();
        }

        private void mnuCapnhatSoluongSach_Click(object sender, EventArgs e)
        {

        }
        #endregion
        #region Menu Quản lý sách
        private void mnuTheloai_Click(object sender, EventArgs e)
        {

        }

        private void mnuNhaxuatban_Click(object sender, EventArgs e)
        {
            if (CheckExistForm("frmTblNXBList")) return;
            // Tạo mới form Nhà xuất bản
            frmTblNXBList childForm = new frmTblNXBList();
            // Đặt thuộc tính MdiParent
            childForm.MdiParent = this;
            // Hiển thị
            childForm.Show();
        }

        private void mnuSach_Click(object sender, EventArgs e)
        {
            if (CheckExistForm("frmTblSACHList")) return;
            // Tạo mới form Sách
            frmTblSACHList childForm = new frmTblSACHList();
            // Đặt thuộc tính MdiParent            
            childForm.MdiParent = this;
            childForm.Show();
        }

        private void mnuKiemkeSach_Click(object sender, EventArgs e)
        {

        }
        #endregion
        #region Menu Thống kê
        private void mnuTKDausach_Click(object sender, EventArgs e)
        {
            if (CheckExistForm("frmTblSACHList")) return;
            frmTblSACHList childForm = new frmTblSACHList();
            childForm.MdiParent = this;
            childForm.Show();
        }

        private void mnuTKBansach_Click(object sender, EventArgs e)
        {

        }

        private void mnuTKBosung_Click(object sender, EventArgs e)
        {

        }
        #endregion
        public bool CheckExistForm(string formName)
        {
            foreach (Form cForm in this.MdiChildren)
            {

                if (cForm.Name == formName)
                {
                    cForm.Activate();
                    return true;
                }
            }
            return false;
        }
        public void ShowAllWindows()
        {
            foreach (Form cForm in this.MdiChildren)
            {
                MessageBox.Show(cForm.Name);                
            }            
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
           
        }

        private void thoátToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }        
       
    }
}
